package com.kkb.service.billmanager.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kkb.bean.BillTable;
import com.kkb.dao.BillTableMapper;
import com.kkb.service.billmanager.BillManagerService;
import com.kkb.vo.profitmanager.req.SelectBillReq;
import com.kkb.vo.profitmanager.req.SelectMoneyByTime;
import com.kkb.vo.profitmanager.req.SelectOverviewReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Service
public class BillManagerServiceImpl implements BillManagerService {

    @Autowired
    private BillTableMapper billTableMapper;
    /**
     * 查询帐单
     * @param param
     * @return
     */
    @Override
    public PageInfo<BillTable> selectBill(SelectBillReq param) {
        //创建tkmybatis查询参数
        BillTable bill = new BillTable();
        bill.setSellerId(param.getSellerId());
        //1.指定分页数据
        PageHelper.startPage(param.getPageNum(),param.getPageSize());
        //2.查询数据
        List<BillTable> bills = billTableMapper.select(bill);
        //3.创建分页工具类
        PageInfo<BillTable> billTablePageInfo = new PageInfo<>(bills);
        return billTablePageInfo;
    }

    @Override
    public BigDecimal selectCommission(SelectOverviewReq param) {
        param.setBillType(1);
        return billTableMapper.selectAndSumByType(param);
    }

    @Override
    public BigDecimal selectBonus(SelectOverviewReq param) {
        param.setBillType(2);
        return billTableMapper.selectAndSumByType(param);
    }

    @Override
    public BigDecimal selectWenkuExcitation(SelectOverviewReq param) {
        param.setBillType(3);
        return billTableMapper.selectAndSumByType(param);
    }

    @Override
    public BigDecimal selectAdExcitation(SelectOverviewReq param) {
        param.setBillType(4);
        return billTableMapper.selectAndSumByType(param);
    }

    @Override
    public BigDecimal selectMoneyByTime(Integer sellerId) {
        return billTableMapper.selectMoneyByTime(sellerId);
    }
}
